﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace gChartSharp
{
    /// <summary>
    /// http://code.google.com/apis/chart/#fill_area_marker
    /// </summary>
    public class FillAreaParam : IFill
    {

        /// <summary>
        /// The name of the API
        /// </summary>
        public string Name { get { return "chm"; } }


        /// <summary>
        /// Get the FillType
        /// </summary>
        public virtual FillType FillType { get { return FillType.b; } }


        /// <summary>
        /// The fill area color
        /// </summary>
        public Color Color { get; set; }


        /// <summary>
        /// The index of the line at which the fill starts. This is determined by the order 
        /// in which data sets are specified with chd. The first data set specified has an 
        /// index of zero (0), the second 1, and so on.
        /// </summary>
        public int StartLineIndex { get; set; }


        /// <summary>
        /// The index of the line at which the fill ends. This is determined by the order 
        /// in which data sets are specified with chd. The first data set specified has an 
        /// index of zero (0), the second 1, and so on.
        /// </summary>
        public int EndLineIndex { get; set; }


        /// <summary>
        /// Initialize the default constructor with default values
        /// </summary>
        public FillAreaParam()
            : this(Color.Black, 0, 0) { }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="color"></param>
        /// <param name="startLineIndex"></param>
        /// <param name="endLineIndex"></param>
        public FillAreaParam(Color color, int startLineIndex, int endLineIndex)
        {
            this.Color = color;
            this.StartLineIndex = startLineIndex;
            this.EndLineIndex = endLineIndex;
        }


        /// <summary>
        /// Render the API text
        /// </summary>
        /// <returns></returns>
        public string Render()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(String.Format("{0},{1},{2},{3},0", this.FillType.ToString(),
                this.Color.ToHTML(), this.StartLineIndex.ToString(), this.EndLineIndex.ToString()));

            return sb.ToString();
        }
    }
}
